package com.harmony.volley.sample.ui.slice;

import com.harmony.volley.sample.ResourceTable;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.components.Component;

public class MainAbilitySlice extends AbilitySlice {
    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_ability_main);
        //HttpUrlConnection实现
        findComponentById(ResourceTable.Id_get_request_http_url_connection_btn).setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                HomeSlice.start(MainAbilitySlice.this, HomeSlice.TYPE_HTTP_URL_CONNECTION);
            }
        });
        //HttpClient实现
        findComponentById(ResourceTable.Id_get_request_http_client_btn).setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                HomeSlice.start(MainAbilitySlice.this, HomeSlice.TYPE_HTTP_CLIENT);
            }
        });
        //OkHttp实现
        findComponentById(ResourceTable.Id_get_request_okhttp_btn).setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                HomeSlice.start(MainAbilitySlice.this, HomeSlice.TYPE_OKHTTP);
            }
        });
        //AsyncHttpClient实现
        findComponentById(ResourceTable.Id_get_request_async_http_client_btn).setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                HomeSlice.start(MainAbilitySlice.this, HomeSlice.TYPE_ASYNC_HTTP_CLIENT);
            }
        });
    }
}